#include<bits/stdc++.h>
#define MAXN 100005
using namespace std;
int n,a[MAXN],cnt[MAXN],num1,cnum1,num2,cnum2,cntd;
int sum,ans;
bool flag=false;
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cnt[a[i]]++;
        sum+=a[i];
    }
    ans=n,sum=n;
    for(int i=1;i<=MAXN;i++){
        if(cnt[i]!=0){
            sum=sum-cnt[i];
            if(sum==0) break;
            if(cnt[i]<=sum) ans=sum;
            else if(cnt[i]>sum) ans=cnt[i];
        }
    }
    cout<<ans;
    return 0;
}
